package com.arcvideo.acsplayer.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class IpUtil {

	public static boolean isValidUserName(String userName) {
		boolean flag = false;
		Pattern pattern = Pattern.compile("[a-zA-Z]{1}([a-zA-Z0-9]+)");
		Matcher m = pattern.matcher(userName);
		flag = m.matches();
		return flag;
	}

	public static boolean isIPAddress(String ipaddr) {
		if (ipaddr == null || ipaddr.isEmpty())
			return false;

		boolean flag = false;
		Pattern pattern = Pattern
				.compile("\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
		Matcher m = pattern.matcher(ipaddr);
		flag = m.matches();
		return flag;
	}
}
